import request from '/@/utils/request';
//文章分类
const typeUrl = '/product/admin/category';
const cateType = 1; //1文章分类；2下载分类;3新品分类

//文章
const articleUrl = '/product/admin/manage';
const articleType = 1; //类型;type;1文章,2下载

/**
 * 文章
 * @param params 要传的参数值
 * @returns 返回接口数据
 * 文章api接口集合
 */
export function useArticleApi() {
	return {
		getArticleCateList: (params) => {
			return request({
				url: `${typeUrl}/list`,
				method: 'post',
				data: { ...params, type: cateType },
			});
		},
		addArticleCate: (params) => {
			return request({
				url: `${typeUrl}/add`,
				method: 'post',
				data: { ...params, type: cateType },
			});
		},
		editArticleCate: (params) => {
			return request({
				url: `${typeUrl}/update`,
				method: 'post',
				data: { ...params, type: cateType },
			});
		},
		delArticleCate: (id) => {
			return request({
				url: `${typeUrl}/del`,
				method: 'post',
				data: { id },
			});
		},
		getArticleList: (params) => {
			return request({
				url: `${articleUrl}/list`,
				method: 'post',
				data: { ...params, type: articleType },
			});
		},
		addArticle: (params) => {
			return request({
				url: `${articleUrl}/add`,
				method: 'post',
				data: { ...params, type: articleType },
			});
		},
		editArticle: (params) => {
			return request({
				url: `${articleUrl}/update`,
				method: 'post',
				data: { ...params, type: articleType },
			});
		},
		delArticle: (id) => {
			return request({
				url: `${articleUrl}/del`,
				method: 'post',
				data: { id },
			});
		},
	};
}
